import java.util.Arrays;

public class Exercise1 {
        public int removeDuplicates(int[] nums) {
            int n = nums.length;
            int fast = 2;
            int slow = 2;
            while (fast < n) {
                if (nums[fast] != nums[slow - 2]) {
                    nums[slow] = nums[fast];
                    slow++;
                }
                fast++;
            }
            for (int i = 0 ;i < slow;i++) {
                System.out.print(nums[i]+" ");
            }
            System.out.println();
            return slow;
        }
}
